'''
TwistedSim script for PING-PONG tutorial
@author: Hatem Oraby
'''
import twistedSim.simManager as simManager 
from twistedSim.moduleHandler import twistedH
from twistedSim import simConfig

def main():
    trackerIp = '127.0.0.1'
    machine = simManager.Machine()

    #Tracker
    trackerModule = simManager.Module('tracker', handler = twistedH())
    simManager.SimManager.addModule(trackerModule, machine)
    
    #Module 2: Client 
    clientSysArgs = trackerIp +":2000"
    peerModule = simManager.Module('peer', twistedH(), sysArgs = clientSysArgs)
    simManager.SimManager.addModule(peerModule, machine)
    
    simConfig.Network.seedPortGeneration(30)
    simConfig.Network.fixedSendDelay = False
    simConfig.Network.seedSendDelay(40)
    simManager.SimManager.run()

if __name__ == '__main__':
    main()